//
//  FourthViewController.m
//  UI豆瓣2015到2016跨年作业
//
//  Created by LHY on 15/12/31.
//  Copyright © 2015年 Lanou 32 李昊宇. All rights reserved.
//

#import "FourthViewController.h"
#import "TL1View.h"
#import "UpViewController.h"
#import "TableViewController.h"
@interface FourthViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic , retain) UIBarButtonItem *bar;
@property (nonatomic , retain) UITableView *tableView;
@property (nonatomic , retain) NSArray *array;
@end

@implementation FourthViewController

- (void)dealloc
{
    [_tableView release];
    [super dealloc];
}






- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.navigationItem.title = @"我的";
     self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.1 green:0.5 blue:0.5 alpha:1];
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:(UITableViewStylePlain)];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    
    
    
    
    self.bar = [[UIBarButtonItem alloc] initWithTitle:@"登陆" style:(UIBarButtonItemStylePlain) target:self action:@selector(action:)];
    _bar.tintColor = [UIColor blackColor];
    
    self.navigationItem.rightBarButtonItem = _bar;
    self.array = [NSArray arrayWithObjects:@"我的活动",@"我的电影", @"清除缓存", nil];
  
   


}

- (void)action:(UIBarButtonItem *)action{
   
    UpViewController *up = [[UpViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:up];
    
    up.blockZC = ^(NSString *str) {
        _bar.title = str;
    
    };
    
    up.fourthNav = self.navigationController;
    [self presentViewController:nav animated:YES completion:^{
        
    }];
    
//    [self.navigationController pushViewController:nav animated:YES];
    [up release];

}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {


    return _array.count;

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = _array[indexPath.row];
    return cell;




}





- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        TableViewController *table = [[TableViewController alloc] init];
        table.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:table animated:YES];
        [table release];
        
        
        
    }




}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
